<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="css-01.css" />
    <title>水平居中</title>
  </head>
  <body>
    <div class="middle">
      <h1>盒子水平居中</h1>
      <h2>1. 行内块元素</h2>
      <div class="middle-block">
        <div class="middle-inline"></div>
      </div>
      <h2>2. 固定宽元素使用margin: auto</h2>
      <div class="middle-margin">
        <div class="middle-auto"></div>
      </div>
      <h2>3. 相对定位搭配绝对定位(子绝父相)</h2>
      <div class="middle-relative">
        <div class="middle-absolute"></div>
      </div>
    </div>
  </body>
</html>
